//
//  DetailforActFirstVC.m
//  XDCommonApp
//
//  Created by xindaoapp on 14-3-10.
//  Copyright (c) 2014年 XD-XY. All rights reserved.
//

#import "DetailforActFirstVC.h"
#import "XDTools.h"
#import "XDHeader.h"
#import "WaterDetailViewController.h"
#import "UIImageView+WebCache.h"
#import "UMSocial.h"
#import "SearchViewController.h"
#import "DetailOrgnizerCell.h"

#define dHeightForHeader 36.0

@interface DetailforActFirstVC ()

{
    NSString *artNameStr;
    NSString *activeDesign;
    NSString *activityIntroduce;
    NSString *activityPosition;
    NSString *activitySponsor;// 主办
    NSString *activityTime;
    NSString *activityTitle;
    NSString *organizer;//
    NSString *activityUrl;
    NSArray *actArray;
    
    NSString *organizationId;
    NSString *organizationName;
    
    float varHeight;
    UILabel *contLabel;
    UIImageView *arrowIV;

    UILabel *posLb;
    UIImageView *nextLvIV;
    BOOL isClicked;
    
    float conY;
}

@end

@implementation DetailforActFirstVC
//@synthesize <#property#>

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    
    actArray = [[NSArray alloc]init];
    activityTitle = @"";
    activityTime = @"";
    artNameStr = @"";
    activitySponsor = @"";
    activeDesign = @"";
    activityPosition = @"";
    activityIntroduce = @"";
    
    isClicked = NO;
    
    [self getXmlData];
    
//    [self initWidget];
}

- (void)initWidget
{
    self.titleLabel.text = @"活动详情";
    self.titleLabel.font = [UIFont boldSystemFontOfSize:17];
    self.titleLabel.textColor = TEXTBLACKCOLORE;
    
//    self.shareView = [[XDShareView alloc] initWithFrame:CGRectMake(0, UI_STATUS_BAR_HEIGHT, UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT)];
//    _shareView.delegate = self;
//    _shareView.backgroundColor = [UIColor whiteColor];
//    [self.view addSubview:_shareView];
//   // [_shareView bringSubviewToFront:self.view];
//    _shareView.hidden =YES;

    self.detailActTableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0, UI_SCREEN_WIDTH,self.contentView.frame.size.height) style:UITableViewStylePlain];
    _detailActTableView.delegate = self;
    _detailActTableView.dataSource = self;
    _detailActTableView.backgroundColor = [UIColor clearColor];

    [self.contentView addSubview:_detailActTableView];
//    [_detailActTableView reloadData];
}
#pragma mark  --------------tableView delegate----------------

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0||section==1){
        return 1;
    }else if(section == 2){
    
        return actArray.count;
    }
    return 1;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
   
    return 3;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section==0) {
        return 0;
    }
    if (section==2) {
        return 100;
    }
    return dHeightForHeader;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    NSArray * array;
    CGFloat headerHeight=0;
    
       
        array=@[@"0",@"活动介绍",@"参展机构"];
        headerHeight = dHeightForHeader;
    
    UIView * view;
    
    if (section==2) {
       
        headerHeight = 100;
        
        view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, headerHeight)];
        view.backgroundColor = RGBA(217, 217, 217, 1);
        UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, UI_SCREEN_WIDTH-15, 36)];
        label.textColor = TEXTBLACKCOLORE;
        label.font = [UIFont systemFontOfSize:15];
        label.backgroundColor = [UIColor clearColor];
        //    label.backgroundColor = [UIColor colorWithRed:224/255.0 green:224/255.0 blue:224/255.0 alpha:1.0];
        label.text = [array objectAtIndex:section];
        [view addSubview:label];
        if (actSearchBar) {
            [actSearchBar removeFromSuperview];
            actSearchBar = nil;
        }
        if (!actSearchBar){
            actSearchBar = [[XDSearchView alloc]initWithFrame:CGRectMake(0, 36, 320, 45)];
            actSearchBar.backgroundColor = UIColorFromRGB(0xdbdada);
            actSearchBar.mytextField.placeholder = @"请输入展位号画廊，艺术家或作品名";
            //                    actSearchBar setc
            //                actSearchBar.showsCancelButton = NO;
            actSearchBar.delegate = self;
            [view addSubview:actSearchBar];
        }
        return view;
        
        
    }else{
    
        UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, headerHeight)];
        view.backgroundColor = RGBA(217, 217, 217, 1);
        UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, UI_SCREEN_WIDTH-15, headerHeight)];
        label.textColor = TEXTBLACKCOLORE;
        label.font = [UIFont systemFontOfSize:15];
        label.backgroundColor = [UIColor clearColor];
        //    label.backgroundColor = [UIColor colorWithRed:224/255.0 green:224/255.0 blue:224/255.0 alpha:1.0];
        label.text = [array objectAtIndex:section];
        [view addSubview:label];
        
        return view;
    }
    
   
    return nil;
    
}


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    if (indexPath.section == 0){
        if (indexPath.row == 0){
            return 461/2.0f+20/2.0f+3/2.0f;
        }
        return 461/2.0f+20/2.0f+10/2.0f;
    }else if(indexPath.section==1){
//        if (indexPath.row == 0){
//            return 20/2.0f+82/2.0f+10;
//        }
//        return 20/2.0f+82/2.0f;
        if (!isClicked) {
            return 110;
        }
        //        return 20/2.0f+82/2.0f;
        return varHeight;
        
    }else {
    
        return 60.0f;
    
    }
}


-(UITableViewCell * )tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(tableView == _detailActTableView){
       

  
        if (indexPath.section == 0&&indexPath.row==0) {
            
            static NSString * cellName = @"cell";
            UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellName];
            if (cell == nil){
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
                
                cell.backgroundColor = [UIColor clearColor];
            }
            
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            UIFont *actFont = [UIFont boldSystemFontOfSize:15];
            if (!actNameLb) {
            
                actNameLb = [[UILabel alloc]init];
                actNameLb.frame = CGRectMake(15, 10,UI_SCREEN_WIDTH, 0);
                actNameLb.font = actFont;
                actNameLb.numberOfLines = 0;
                actNameLb.backgroundColor = [UIColor clearColor];
            
           
            
            CGSize size = CGSizeMake(300, 200.0f);
            NSString *str = @"鲁本斯、凡戴克与佛兰德斯画派——列支敦士登王室珍藏展";
//            NSString *str = activityTitle;
            size = [str sizeWithFont:actFont constrainedToSize:CGSizeMake(actNameLb.frame.size.width, MAXFLOAT) lineBreakMode:NSLineBreakByWordWrapping];
            //根据计算结果重新设置label的尺寸
            [actNameLb setFrame:CGRectMake(15, 10, UI_SCREEN_WIDTH-30, size.height)];
            actNameLb.text = str;
            [cell.contentView addSubview:actNameLb];
            }
            if (!actImgV) {
                actImgV = [[UIImageView alloc]initWithFrame:CGRectMake(actNameLb.frame.origin.x, height_y(actNameLb)+10, 90, 130)];
                actImgV.backgroundColor = UIColorFromRGB(0xdbdada);


            NSString * imageUrl = [NSString stringWithFormat:@"%@%@",ImageMainUrl,activityUrl];
            NSString * urlstring = [imageUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//            actImgV.tag = 200;
            [actImgV setImageWithURL:[NSURL URLWithString:urlstring] placeholderImage:[UIImage imageNamed:@"placehold_image"]];
            
            [cell.contentView addSubview:actImgV];

            }

            if (!timeLabel) {
                timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(width_x(actImgV)+10, actImgV.frame.origin.y, 200, 20)];
                timeLabel.backgroundColor = [UIColor clearColor];
//
//           timeLabel.text = @"时间：2014/02/22-2014/04/18";
            timeLabel.font = [UIFont systemFontOfSize:12];
            timeLabel.textColor = TEXTBLACKCOLORE4;
            [cell.contentView addSubview:timeLabel];
            }
            if (!posLb) {
                posLb = [[UILabel alloc ]initWithFrame:CGRectMake(timeLabel.frame.origin.x, height_y(timeLabel), 40, timeLabel.frame.size.height)];
                posLb.backgroundColor = [UIColor clearColor];
                posLb.text = @"位置：";
                posLb.textColor = TEXTBLACKCOLORE4;
                posLb.font = timeLabel.font;
                [cell.contentView addSubview:posLb];
            }


            if (!positionLabel) {
                positionLabel = [[UILabel alloc]initWithFrame:CGRectMake(width_x(posLb), posLb.frame.origin.y+10, 140, 30)];
                positionLabel.backgroundColor = [UIColor clearColor];

                positionLabel.numberOfLines = 0;
            positionLabel.textColor = TEXTBLACKCOLORE4;
            positionLabel.font = timeLabel.font;
            
            CGSize Psize = CGSizeMake(140, 2000.0f);
            NSString *Pstr =activityPosition;// @"北京  朝阳  尤伦斯当代\n艺术中心  UCCA 甬道、";
            Psize = [Pstr sizeWithFont:posLb.font constrainedToSize:CGSizeMake(positionLabel.frame.size.width, MAXFLOAT) lineBreakMode:NSLineBreakByWordWrapping];
            
            NSAttributedString *attributedString =[[NSAttributedString alloc] initWithString:Pstr attributes:@{NSKernAttributeName : @(5.0f)}];
            
            [positionLabel setAttributedText:attributedString];

            positionLabel.text = Pstr;
            //根据计算结果重新设置label的尺寸
            [positionLabel setFrame:CGRectMake(width_x(posLb), posLb.frame.origin.y+2, 140, Psize.height)];
           
        
           
            [cell.contentView addSubview:positionLabel];
        //

            }
            if (!joinLabel) {
                joinLabel = [[UILabel alloc]initWithFrame:CGRectMake(posLb.frame.origin.x, height_y(positionLabel)+5, timeLabel.frame.size.width, timeLabel.frame.size.height)];
                joinLabel.font = posLb.font;
                joinLabel.backgroundColor = [UIColor clearColor];
                //            joinLabel.text = @"参展：季大纯";
                joinLabel.textColor = TEXTBLACKCOLORE4;
                [cell.contentView addSubview:joinLabel];
            }
            if (!hostLabel) {
                hostLabel = [[UILabel alloc]initWithFrame:CGRectMake(posLb.frame.origin.x, height_y(joinLabel), joinLabel.frame.size.width, joinLabel.frame.size.height)];
                hostLabel.backgroundColor = [UIColor clearColor];
                hostLabel.font = joinLabel.font;
                hostLabel.textColor = TEXTBLACKCOLORE4;
                //            hostLabel.text = @"主办：尤伦斯当代艺术中心UCCA";
                [cell.contentView addSubview:hostLabel];
            }
            

            if (!designLabel) {

                designLabel = [[UILabel alloc]initWithFrame:CGRectMake(posLb.frame.origin.x, height_y(hostLabel), joinLabel.frame.size.width, joinLabel.frame.size.height)];
                designLabel.backgroundColor = [UIColor clearColor];
                designLabel.font = joinLabel.font;
                designLabel.textColor = TEXTBLACKCOLORE4;
                //            designLabel.text = @"策展人：郑晓俊";
//                [cell.contentView addSubview:designLabel];

            }

            actNameLb.text = activityTitle;
            timeLabel.text = [NSString stringWithFormat:@"时间:  %@",activityTime];
            hostLabel.text = [NSString stringWithFormat:@"主办:  %@",activitySponsor];
            joinLabel.text = [NSString stringWithFormat:@"参展:  %@",organizer];//
//            designLabel.text =[NSString stringWithFormat:@"策展人:  %@",activeDesign];
            positionLabel.text =[NSString stringWithFormat:@"%@",activityPosition];
            
            UIView * lineView = [[UIView alloc] initWithFrame:CGRectMake(0, height_y(actImgV)+10, UI_SCREEN_WIDTH, 1)];
            lineView.backgroundColor = RGBA(219, 219, 219, 1);
            [cell.contentView addSubview:lineView];
            if (!shareBtn) {
                shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                shareBtn.frame = CGRectMake(0, height_y(lineView), UI_SCREEN_WIDTH, 44);
                shareBtn.backgroundColor = [UIColor clearColor];

                //            UIImageView *shareIV = [[UIImageView alloc]initWithFrame:CGRectMake(UI_SCREEN_WIDTH/2-15, 11, 22, 22)];
                //            shareIV.image = [UIImage imageNamed:@"share_icon@2x"];


                UIImageView *shareIV = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"share_icon"]];
                shareIV.frame = CGRectMake(UI_SCREEN_WIDTH/2-9, 7, 18, 16);

                UILabel *shareLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 22, UI_SCREEN_WIDTH, 22)];
                shareLabel.backgroundColor = [UIColor clearColor];
                shareLabel.textColor  = TEXTBLACKCOLORE3;
                shareLabel.font = [UIFont systemFontOfSize:11];
                shareLabel.text = [NSString stringWithFormat:@"分享"];
                shareLabel.textAlignment = NSTextAlignmentCenter;

                //                [scaneBtn addSubview:shareIV];
                [shareBtn addSubview:shareLabel];
                //                [scaneBtn addTarget:self action:@selector(sharebtnClick) forControlEvents:UIControlEventTouchUpInside];

                [shareBtn addSubview:shareIV];
                [shareBtn addTarget:self action:@selector(shareBtnClick) forControlEvents:UIControlEventTouchUpInside];
                
                
                [cell.contentView addSubview:shareBtn];
            }

            
            UIView * lineView2 = [[UIView alloc] initWithFrame:CGRectMake(0, height_y(shareBtn), UI_SCREEN_WIDTH, 1)];
            lineView2.backgroundColor = RGBA(219, 219, 219, 1);
            [cell.contentView addSubview:lineView2];
            
//            }

            return cell;
            
        }else if (indexPath.section==1&&indexPath.row==0){
        //活动介绍
            static NSString * cellName1 = @"cell1";
            UITableViewCell * cell1 = [tableView dequeueReusableCellWithIdentifier:cellName1];
            if (cell1 == nil){
                cell1 = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName1];
//                cell1.backgroundColor = UIColorFromRGB(0xdbdada);
                cell1.selectionStyle = UITableViewCellSelectionStyleNone;
                //            cell.backgroundColor = UIColorFromRGB(0xdbdada);
                cell1.backgroundColor = [UIColor clearColor];
            }
        

            if (!contLabel) {
                contLabel = [[UILabel alloc ]init];
                contLabel.backgroundColor = [UIColor clearColor];
                contLabel.font = [UIFont systemFontOfSize:13];
                contLabel.frame = CGRectMake(15, 5, 290, 80);
                contLabel.text = activityIntroduce;
                contLabel.numberOfLines = 4;
                contLabel.lineBreakMode = NSLineBreakByTruncatingTail;
                
                [cell1.contentView  addSubview:contLabel];
                
                arrowIV = [[UIImageView alloc ]init];
                arrowIV.backgroundColor = [UIColor clearColor];
                arrowIV.frame = CGRectMake(150, height_y(contLabel), 10, 10);
                arrowIV.image = [UIImage imageNamed:@"shaixuan_down"];
                [cell1.contentView addSubview:arrowIV];
            }
            return cell1;
            
        }else if (indexPath.section == 2){

        //参展机构
            
//            if (cell != nil)
//            {
//                [cell removeFromSuperview];//处理重用
//            }
//            NSArray * array;
//            array=@[@"0",@"A1A2 大未来林舍画廊",@"A3 东站画廊",@"A4 沪申画廊",@"A5A6 凯撒贝赛什",@"A7 翡翠画廊",@"A8 悲鸿画廊"];
           
//            if([NSIndexPath indexPathForRow:0 inSection:2] == indexPath){
//            
//            }
            static NSString * cellName3 = @"cell3";
            DetailOrgnizerCell * cell3 = [tableView dequeueReusableCellWithIdentifier:cellName3];
            if (cell3 == nil){
                cell3 = [[DetailOrgnizerCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName3];
                
                cell3.backgroundColor = [UIColor clearColor];
                
            }
            
            if (actArray.count==0) {
                DDLOG(@"List no avilable Data");
            }else{
                
//                    cell3.textLabel.frame = CGRectMake(10, 10, 200, 20);

                cell3.ognizerLabel.text = [[actArray objectAtIndex:indexPath.row]valueForKey:@"organizationName"];

                cell3.ognizerLabel.font = [UIFont systemFontOfSize:16];



//                    nextLvIV = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"launh_sure"]];
//                    nextLvIV.frame = CGRectMake(290, 20, 15, 20);
//                    nextLvIV.contentMode = UIViewContentModeScaleAspectFit;
//                    nextLvIV.backgroundColor = [UIColor clearColor];
//                    [cell3.contentView addSubview:nextLvIV];

                
            }
            
            return cell3;
            
        }
        
    }
    return nil;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    [self dismissKeyBoard];
    
    if (indexPath.section == 1) {
        
        NSDictionary * tdic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:13],NSFontAttributeName,nil];
        CGSize  actualsize =[activityIntroduce boundingRectWithSize:CGSizeMake(290, 400) options:NSStringDrawingUsesLineFragmentOrigin  attributes:tdic context:nil].size;
        
        isClicked = !isClicked;
        
        if (isClicked) {
            
            varHeight = actualsize.height+20;
            
            contLabel.frame = [XDTools xyAutoSizeOfWidget:contLabel andSize:CGSizeMake(290, 400) andtextFont:13];
            contLabel.numberOfLines = 0;
            
//            arrowIV.frame = CGRectMake(150, height_y(contLabel), 10, 10);
            arrowIV.image = [UIImage imageNamed:@"shaixuan_up"];
        }else{
            
            contLabel.frame = CGRectMake(15, 5, 290, 80);
            contLabel.numberOfLines = 4;
//            arrowIV.frame = CGRectMake(150, height_y(contLabel), 10, 10);
            arrowIV.image = [UIImage imageNamed:@"shaixuan_down"];
        }
        
        
        [tableView reloadData];
        // section
//        NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:1];
//        [tableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic];
//        cell
        
//        NSIndexPath *indexPath=[NSIndexPath indexPathForRow:0 inSection:1];
//        [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
        
        NSLog(@"size.height = %f",varHeight);
        NSLog(@" cmmmmm = %@",activityIntroduce);
        
        
        //        NSIndexPath *indexPath=[NSIndexPath indexPathForRow:0 inSection:1];
        //        [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
        
    }

    
    if(indexPath.section == 2){
        organizationId = [[actArray objectAtIndex:indexPath.row]valueForKey:@"organizationId"];
        organizationName = [[actArray objectAtIndex:indexPath.row]valueForKey:@"organizationName"];
        WaterDetailViewController *waterVC = [[WaterDetailViewController alloc] init];

        waterVC.orgernizeId = organizationId;
        waterVC.signal = @"4";
        [self.navigationController pushViewController:waterVC animated:YES];
        
        DDLOG(@"跳转到瀑布流");
    }
}

#pragma mark  ---------------UISearchBar Delegate ------------

-(void)XDSearhViewShouldBeginEditing{
    
    CGRect rect = self.contentView.frame;
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.3];
    if (conY>285) {
        conY=285;
    }
    rect.origin.y = -285+conY;
    self.view.frame = rect;
    [UIView commitAnimations];
}
-(void)XDSearchViewShouldReturn{
    
    [self dismissKeyBoard];
    SearchViewController * svc = [[SearchViewController alloc] init];
    svc.titleStr =  actSearchBar.mytextField.text;
    svc.activityId = self.idStr;
    [self.navigationController pushViewController:svc animated:YES];
    
}
-(void)XDSearchViewCanelbuttonClick{
    
    [self dismissKeyBoard];
   
}
-(void)XDSearchTextFieldDidChange{

}



- (void)dismissKeyBoard{

    [actSearchBar.mytextField resignFirstResponder];
    CGRect rect = self.contentView.frame;
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.3];
    rect.origin.y = 0.0f;
    self.view.frame = rect;
    [UIView commitAnimations];

}
//- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
//    
//    [self dismissKeyBoard];
//}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    conY = scrollView.contentOffset.y;
    NSLog(@"cony  =  %f",conY);
    
}

#pragma mark ================XDShareView Delegate===============
-(void)shareViewBtnCLick:(UIButton *)button
{
    
    int tag = button.tag - SHAREBTNTAG;
    //设置分享内容和回调对象
    if (tag == 0){
        //微信会话
        [UMSocialData defaultData].extConfig.wxMessageType = UMSocialWXMessageTypeText;
        [[UMSocialControllerService defaultControllerService] setShareText:@"分享到微信－找画APP" shareImage:[UIImage imageNamed:@"Icon"] socialUIDelegate:self];
        [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToWechatSession].snsClickHandler(self,[UMSocialControllerService defaultControllerService],YES);
    }else if (tag == 1){
        //朋友圈分享
        [[UMSocialControllerService defaultControllerService] setShareText:@"分享到朋友圈－找画APP" shareImage:[UIImage imageNamed:@"Icon"] socialUIDelegate:self];
        [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToWechatTimeline].snsClickHandler(self,[UMSocialControllerService defaultControllerService],YES);
    }else if (tag == 2){
        //新浪微博
        [[UMSocialControllerService defaultControllerService] setShareText:@"分享到新浪微博－找画APP" shareImage:[UIImage imageNamed:@"Icon"] socialUIDelegate:self];
        [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToSina].snsClickHandler(self,[UMSocialControllerService defaultControllerService],YES);
    }else if (tag == 3){
        //复制链接地址
        [[UIPasteboard generalPasteboard] setString:[NSString stringWithFormat:@"%@%@",ImageMainUrl,activityUrl]];
        [XDTools showTips:@"复制成功" toView:_shareView];
    }else if (tag == 4){
        //关闭
        [_shareView removeFromSuperview];
        _shareView.hidden =YES;
    }
}

#pragma mark  -------- DataSouceManager------------

- (void)getXmlData
{
//    NSString *id_Str = _idStr;
//    NSString *type_Str = _typeStr;
    if ([XDTools NetworkReachable]){
        NSString *body = [NSString stringWithFormat:@" <ActivityDetailById xmlns=\"http://tempuri.org/\">"
                          "<id>%@</id>"
                          "<type>%@</type>"
                          "</ActivityDetailById>",_idStr,_typeStr];
        
        __weak ASIFormDataRequest *request = [XDTools postRequestWithDict:body API:ACTIVITYDETAILBYID];
        [request setCompletionBlock:^{
            [XDTools hideProgress:self.contentView];
            //[XDTools hideProgress:self.contentView];
            NSString *responseString = [request responseString];
            // NSDictionary *tempDic = [XDTools  JSonFromString:responseString];
            DDLOG(@"responseString:%@", responseString);
            
            [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
            int statusCode = [request responseStatusCode];
            NSString *soapAction = [[request requestHeaders] objectForKey:@"SOAPAction"];
            
            NSArray *arraySOAP =[soapAction componentsSeparatedByString:@"/"];
            int count = [arraySOAP count] - 1;
            NSString *methodName = [arraySOAP objectAtIndex:count];
            
            // Use when fetching text data
            NSString *result = nil;
            if (statusCode == 200) {
                //表示正常请求
                result = [SoapXmlParseHelper SoapMessageResultXml:responseString ServiceMethodName:methodName];
                NSDictionary  *responseDict = [XDTools JSonFromString:result];
                if ([[responseDict objectForKey:@"code"] intValue]==0){
                    DDLOG(@"res = %@",responseDict);
                   
                    activityTitle = [NSString stringWithFormat:@"%@",[responseDict valueForKey:@"activityTitle"]];
                    
                    if ([activityTitle isEqualToString:@"<null>"]||[activityTitle isKindOfClass:[NSNull class]]) {
                        activityTitle = @"";
                    }
                    
                    activityTime = [NSString stringWithFormat:@"%@",[responseDict valueForKey:@"activityTime"]];
                    
                    if ([activityTime isEqualToString:@"<null>"]||[activityTime isKindOfClass:[NSNull class]]) {
                        activityTime = @"";
                    }
                    
                    artNameStr = [NSString stringWithFormat:@"%@",[responseDict valueForKey:@"activityArtName"]];
                    
                    if ([artNameStr isEqualToString:@"<null>"]||[artNameStr isKindOfClass:[NSNull class]]) {
                        artNameStr = @"";
                    }


                    organizer = [NSString stringWithFormat:@"%@",[responseDict valueForKey:@"organizer"]];

                    if ([organizer isEqualToString:@"<null>"]||[organizer isKindOfClass:[NSNull class]]) {
                        organizer = @"";
                    }

                    activitySponsor = [NSString stringWithFormat:@"%@",[responseDict valueForKey:@"activitySponsor"]];
                    if ([activitySponsor isEqualToString:@"<null>"]||[activitySponsor isKindOfClass:[NSNull class]]) {
                        activitySponsor = @"";
                    }
                    
                    activeDesign = [NSString stringWithFormat:@"%@",[responseDict valueForKey:@"activityDesign"]];
                    if ([activeDesign isEqualToString:@"<null>"]||[activeDesign isKindOfClass:[NSNull class]]) {
                        activeDesign = @"";
                    }
                    
                    activityPosition = [NSString stringWithFormat:@"%@",[responseDict valueForKey:@"activityPosition"]];
                    if ([activityPosition isEqualToString:@"<null>"]||[activityPosition isKindOfClass:[NSNull class]]) {
                        activityPosition = @"";
                    }
                    
                    actArray = [responseDict valueForKey:@"activityOrganizationList"];
                    activityIntroduce = [NSString stringWithFormat:@"%@",[responseDict valueForKey:@"activityIntroduce"]];
                    if ([activityIntroduce isEqualToString:@"<null>"]||[activityIntroduce isKindOfClass:[NSNull class]]) {
                        activityIntroduce = @"";
                    }
                    
                    activityUrl = [NSString stringWithFormat:@"%@",[responseDict valueForKey:@"activityUrl"]];
                   
                    [self initWidget];
                    
                    
                    
//                    [_detailActTableView reloadData];
                    
//                    actNameLb.text = activityTitle;
//                    timeLabel.text = [NSString stringWithFormat:@"时间:  %@",activityTime];
//                    hostLabel.text = [NSString stringWithFormat:@"主办:  %@",activitySponsor];
//                    joinLabel.text = [NSString stringWithFormat:@"参展:  %@",artNameStr];
//                    designLabel.text =[NSString stringWithFormat:@"策展人:  %@",activeDesign];
//                    positionLabel.text =[NSString stringWithFormat:@"%@",activityPosition];
                    
//                    NSIndexPath *indexPath=[NSIndexPath indexPathForRow:0 inSection:1];
//                    [_detailActTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
                    
//                    NSIndexSet *indexSet1=[[NSIndexSet alloc]initWithIndex:1];
//                    [_detailActTableView reloadSections:indexSet1 withRowAnimation:UITableViewRowAnimationAutomatic];
                    
//                    NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:2];
//                    [_detailActTableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic];
                    
                    
                }else{
                    [self initWidget];
                }
            }
        }];
        
        [request setFailedBlock:^{
            [XDTools hideProgress:self.contentView];
        }];
        
        [request startAsynchronous];
        [XDTools showProgress:self.contentView];
    }else{
        [XDTools showTips:brokenNetwork toView:self.contentView];
    }
   
}


//分享
-(void)shareBtnClick
{
    
    self.shareView = [[XDShareView alloc] initWithFrame:CGRectMake(0, UI_STATUS_BAR_HEIGHT, UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT)];
    _shareView.delegate = self;
    _shareView.backgroundColor = [UIColor whiteColor];
    [[UIApplication sharedApplication].keyWindow addSubview:_shareView];
   // [ addSubview:_shareView];
    // [_shareView bringSubviewToFront:self.view];
    _shareView.hidden =YES;
    
    DDLOG_CURRENT_METHOD;
//    [UMSocialSnsService presentSnsIconSheetView:self
//                                         appKey:UMAPPKEY
//                                      shareText:SHARETITLE
//                                     shareImage:[UIImage imageNamed:@"Icon"]
//                                shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina,UMShareToTencent,UMShareToWechatSession,UMShareToWechatTimeline,nil]
//                                       delegate:nil];
    [self dismissKeyBoard];
    _shareView.hidden =NO;
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
